import { $freePost } from '@js/request'
import { UserInfo } from '@src/components/schema/basic';

// 通过账号登录
export async function loginByUsernameRequest (username: string, password: string): Promise<{ userInfo: UserInfo, token: string }> {
  const res = await $freePost('/api/common/user_login', {
    username: username.trim(),
    password: password.trim()
  })
  return res.data
}

// 通过手机号登录
export async function loginByPhoneRequest (zoneNum: string, mobile: string, verification: string ): Promise<{ userInfo: UserInfo, token: string }> {
  const res = await $freePost('/api/common/mobile_login', {
    zoneNum,
    mobile,
    verification
  })
  return res.data
}
